//flaglever.txt - Lever which, when pulled, flips a flag from 0 to 1 and back. No locks
// or other trickery.
//Cell 0,1 - The sdf which is set to 1 or 0 when lever is pulled.
// Cell 2 - skill needed, if 0 none
// Cell 3 - If 1, can't flip back
beginobjectscript; 

variables;

short range = 0;

body;

beginstate INIT_STATE;
	if ((get_memory_cell(0) > 0) || (get_memory_cell(1) > 0)) {
		if (get_flag(get_memory_cell(0),get_memory_cell(1)) > 0) {
			set_object_icon(ME,10);
			}
		}
	break;

beginstate DEAD_STATE;

break;

beginstate START_STATE; // door closed, waiting
break;

beginstate USE_STATE;
	if ((get_memory_cell(2) > 0) && (get_stat_total(24) < get_memory_cell(2))) {
		print_str("Pull Lever: It has a complex locking mechanism, and you can't ");
		print_str("  figure out how to release it.");
		end();
		}
		
	if ((get_memory_cell(0) > 0) || (get_memory_cell(1) > 0)) {
		if (get_flag(get_memory_cell(0),get_memory_cell(1)) > 0) {
			if (get_memory_cell(3) > 0) {
				print_str("Pull Lever: It's stuck. It won't budge.");
				end();
				}
				else {
					set_flag(get_memory_cell(0),get_memory_cell(1),0);
					set_object_icon(ME,10);
					ok_dlog(24,1);
					}
			}
			else {
				set_flag(get_memory_cell(0),get_memory_cell(1),1);
				set_object_icon(ME,11);
				ok_dlog(22,1);
				}
		}
	print_str("Pull Lever: You pull the lever.");
	play_sound(21);
break;
